import { Component, OnInit, Input, OnChanges, Output } from '@angular/core';

import { WorkflowStatus } from './module/workflow-status';
import { ProcessInfo, parame } from './module/process-info';

/**
 * @input:传递过来的值，格式如下
 * {
 * 	data:[{id:number,status:enum,processName:string}],
 * 	processEvgs:Function[],
 * 	callbackEvgs:Function[]
 * }
 * callbackEvgs：传递回调事件， 提供ClickSucCallback，ClickFailCallback，MouseOverCallback及常用鼠标操作事件方法xxxCallback
 * processEvgs：第一个为初始化事件
 * 注意：在定义回调方法的时候，需要实例化类CallbackEvent，通过实例化然后再赋值fun回调参数
 * @export
 * @class WorkflowComponent
 * @implements {OnChanges}
 * @implements {OnInit}
 */
@Component({
    selector: 'workflow-component',
    templateUrl: './workflow.component.html',
    styleUrls: ['./workflow.component.scss']
})

export class WorkflowComponent implements OnChanges, OnInit {
    /**
     * 
     * 
     * @type {ProcessInfo}
     * @memberOf WorkflowComponent
     */
    @Input() processInfo: ProcessInfo;
    /**
     * 
     * 
     * @type {parame[]}
     * @memberOf WorkflowComponent
     */
    parames: parame[];
    /**
     * 
     * 
     * @type {ProcessInfo}
     * @memberOf WorkflowComponent
     */
    currentProcess: ProcessInfo;

    /**
     * Creates an instance of WorkflowComponent.
     * 
     * 
     * @memberOf WorkflowComponent
     */
    constructor() {
    }
    
    /**
     * OnInit接口方法 - workflowComponent初始化事件
     * 
     * 
     * @memberOf WorkflowComponent
     */
    ngOnInit(): void {
        if (this.processInfo && this.processInfo.processEvgs) {
            this.processInfo.processEvgs[0]();
        }
    }
    /**
     * ngOnChanges接口方法 - 对于数据有变动时会执行该方法
     * 
     * 
     * @memberOf WorkflowComponent
     */
    ngOnChanges(): void {
        if (this.processInfo && this.processInfo.data) {
            this.parames = this.processInfo.data;
        }
    }
}